package entity.sparemanage.dto;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import entity.sparemanage.Warehousing;

import java.util.Date;

public class warehouseQueryWrapper {
    public QueryWrapper<Warehousing> queryWrapper(warehouseDto warehouseDto){
        QueryWrapper<Warehousing> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("delete_flag",0);
        if (warehouseDto.getCodeName()!=null){
            String codeName = warehouseDto.getCodeName();
            queryWrapper.like("ware_code",codeName).or().like("ware_name",codeName);
        }
        if (warehouseDto.getWareCode()!=null){
            String wareCode = warehouseDto.getWareCode();
            queryWrapper.like("ware_code",wareCode);
        }
        if (warehouseDto.getWareName()!=null){
            String wareName = warehouseDto.getWareName();
            queryWrapper.like("ware_name",wareName);
        }
        if (warehouseDto.getWareTime()!=null){
            Date wareTime = warehouseDto.getWareTime();
            queryWrapper.eq("ware_time",wareTime);
        }
        if (warehouseDto.getWareType()!=null){
            Integer wareType = warehouseDto.getWareType();
            queryWrapper.eq("ware_type",wareType);
        }
        if (warehouseDto.getWarehouseId()!=null){
            Integer warehouseId = warehouseDto.getWarehouseId();
            queryWrapper.eq("warehouse_id",warehouseId);
        }
        if (warehouseDto.getApplicantId()!=null){
            Integer applicantId = warehouseDto.getApplicantId();
            queryWrapper.eq("applicant_id",applicantId);
        }
        if (warehouseDto.getUpdateTime()!=null){
            Date updateTime = warehouseDto.getUpdateTime();
            queryWrapper.eq("update_time",updateTime);
        }
        return queryWrapper;
    }
}
